package rest

import (
	"net/http"

	"gitee.com/hexug/go-chain-restful-client/common/logger"
)

type User struct {
	Username string
	Password string
}

type Client struct {
	baseURL     string
	headers     http.Header
	client      *http.Client
	cookies     []*http.Cookie
	authType    AuthType
	user_agent  string
	user        *User
	token       string
	log         *logger.Log
	severity    Severity
	proxyAdd    string // 代理地址
	proxyPort   string // 代理端口
	proxyScheme string // 代理协议
}

func NewDefaultClient() *Client {
	log := logger.NewDefaultLog()
	log.L().Debugw("创建客户端")
	log.L().Debugln("日志级别：", logger.DEBUG)
	log.L().Debugw("默认header：Accept-Encoding=gzip")
	return &Client{
		headers: NewDefaultHeader(),
		log:     log,
		client:  http.DefaultClient,
	}
}
func NewLogLevelClient(level logger.Level) *Client {
	log := logger.NewDefaultLog()
	log.SetLevel(level)
	log.L().Debugw("创建客户端")
	log.L().Debugln("日志级别：", level.String())
	log.L().Debugw("默认header：Accept-Encoding=gzip")
	c := http.DefaultClient
	c.Transport = nil
	return &Client{
		headers: NewDefaultHeader(),
		log:     log,
		client:  c,
	}
}

func NewDefaultHeader() http.Header {
	header := http.Header{}
	header.Add("Accept-Encoding", "gzip")
	return header
}
